package Offer2018;

/**
 * Created by 雷文康 on 2018/3/3.
 */
public class Test13 {

    public static void deleteNode(ListNode head, ListNode node) {
        if (head == null || node == null) {
            return;
        }
        //若链表只有头结点
        if(head == node && head.next == null){
            head = null;
            node = null;
            return;
        }
        //删除尾结点
        if (node.next == null) {
            ListNode p = head;
            while (p.next != node) {
                p = p.next;
            }
            p.next = null;
            return;
        }

        node.value = node.next.value;
        node.next = node.next.next;
    }
}
